package aps.module_Core;  //Hah, this was all I had to change for the 1.3.2 port

import aps.module_Core.module_Core.APSBlockTypes;
import net.minecraft.src.ModLoader;
import net.minecraft.src.TileEntity;

public class APSMetaSub
{
	Class<? extends TileEntity> ent; //The subblock's TileEntity class
	String internalName; //The subblock's internal name
	String ingameName; //The subblock's ingame name (i.e. the one players see)
	APSBlockTypes type;
	
	public APSMetaSub(int Index, Class <? extends TileEntity> Ent, String InternalName, String IngameName, APSBlockTypes type)
	{
		ent = Ent;
		internalName = InternalName;
		ingameName = IngameName;
		this.type = type;
		
		if (type == APSBlockTypes.Energy){
			ModLoader.addLocalization(module_Core.APSMetaBlockEnergy.getBlockName() + "." + internalName + ".name", ingameName);
		}
		else{ 
			ModLoader.addLocalization(module_Core.APSMetaBlockMachine.getBlockName() + "." + internalName + ".name", ingameName);
		}
	}
	
	//Allows for a new instance of the subblock's TileEntity to be retrieved
	public TileEntity getBlockEntity()
	{
		try
		{
			return ent.newInstance();
		}
		catch (InstantiationException e) 
		{
			e.printStackTrace();
			return null;
		}
		catch (IllegalAccessException e)
		{
			e.printStackTrace();
			return null;
		}
	}
	
	//Allows for various versions of the subblock's internal name to be retrieved
	public String getInternalName() {return internalName;}
	public String getInternalBlockName() {
		if (type == APSBlockTypes.Energy)
			return module_Core.APSMetaBlockEnergy.getBlockName() + "." + internalName;
		else 
			return module_Core.APSMetaBlockMachine.getBlockName() + "." + internalName;
	}
	public String getInternalItemName() {
		if (type == APSBlockTypes.Energy)
			return module_Core.APSMetaBlockEnergyItem.getItemName() + "." + internalName;
		else 
			return module_Core.APSMetaBlockMachineItem.getItemName() + "." + internalName;
	}
}
